/*
 * @Author: nainaiyi s15037075861@163.com
 * @Date: 2022-09-05 11:43:04
 * @LastEditors: nainaiyi s15037075861@163.com
 * @LastEditTime: 2022-09-05 11:59:25
 * @FilePath: \shopapp\src\store\home\homeReducer.ts
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
import { fetch_data, homeAllAction } from "./homeAction"
export interface homeListType {
    id: string,
    url: string,
    price: number,
    title: string,
    desc: string,
    state: string
}

export interface homeListState {
    homeList: homeListType[]
}

const initState: homeListState = {
    homeList: []
}

export const homeReducer = (state = initState, action: homeAllAction) => {
    switch (action.type) {
        case fetch_data: {
            return {
                ...state,
                homeList: [...state.homeList, ...action.payload]
            }
        }

        default:
            return { ...state }
    }
}